#!/bin/sh

FORM_CONFIG_STATION=/tmp/form_config/
FACTORY_CONFIG_FILE=/etc/tozed_param
MODEM_CONFIG_LOAD_FILE=${FORM_CONFIG_STATION}/modem
UCI_SECTION=modem
mkdir -p ${FORM_CONFIG_STATION}

#export param
cat ${FACTORY_CONFIG_FILE} | grep TZMODEM_ > ${MODEM_CONFIG_LOAD_FILE}
chmod 777 ${MODEM_CONFIG_LOAD_FILE}
. ${MODEM_CONFIG_LOAD_FILE}



cfg -a TZ_ENABLE_AUTO_DIAL="${TZMODEM_AUTO_DIAL}" --section $UCI_SECTION
cfg -a TZ_ENABLE_ROAM="${TZMODEM_ENABLE_ROAM}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_PPP_AUTH_TYPE="${TZMODEM_APN0_AUTH_TYPE}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_PPP_USERNAME="${TZMODEM_APN0_USERNAME}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_PPP_PASSWORD="${TZMODEM_APN0_PASSWORD}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_IP_STACK_MODE="${TZMODEM_APN0_IP_STACK}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_MTU_USB0="${TZMODEM_APN0_MTU}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_APN_NAME="${TZMODEM_APN0_NAME}" --section $UCI_SECTION

if [ ${TZ_LOCK_BAND_ENABLE}"" == "1" ];then
    cfg -a TZ_DIALTOOL2_LTE_BAND_PREF="${TZMODEM_BAND_PREF}" --section $UCI_SECTION
fi
cfg -a TZ_DIALTOOL2_PLMN_LOCK="${TZMODEM_PLMN_LOCK}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_NAT="${TZMODEM_APN0_NAT}" --section $UCI_SECTION
cfg -a TZ_DIALTOOL2_NAT_LOOKBACK="${TZMODEM_APN0_NATLOOKBACK}" --section $UCI_SECTION

if [ "${TZMODEM_NETWORK_MODE}" != "" ]; then
	cfg -a TZ_DIALTOOL2_LTE_MODULE_MODE="${TZMODEM_NETWORK_MODE}" --section $UCI_SECTION
else
	cfg -a TZ_DIALTOOL2_LTE_MODULE_MODE=2 --section $UCI_SECTION
fi

cfg -a TZ_MUTILAPN1_APN_NAME="${TZMODEM_APN1_NAME}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_PROFILE_NAME="${TZMODEM_APN1_PROFILE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_USERNAME="${TZMODEM_APN1_USERNAME}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_PASSWORD="${TZMODEM_APN1_PASSWORD}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_AUTH_TYPE="${TZMODEM_APN1_AUTH_TYPE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_IP_STACK_MODE="${TZMODEM_APN1_IP_STACK}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_MTU="${TZMODEM_APN1_MTU}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_ENABLE="${TZMODEM_APN1_ENABLE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_NAT="${TZMODEM_APN1_NAT}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN1_NAT_LOOKBACK="${TZMODEM_APN1_NATLOOKBACK}" --section $UCI_SECTION

cfg -a TZ_MUTILAPN2_APN_NAME="${TZMODEM_APN2_NAME}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_PROFILE_NAME="${TZMODEM_APN2_PROFILE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_USERNAME="${TZMODEM_APN2_USERNAME}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_PASSWORD="${TZMODEM_APN2_PASSWORD}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_AUTH_TYPE="${TZMODEM_APN2_AUTH_TYPE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_IP_STACK_MODE="${TZMODEM_APN2_IP_STACK}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_MTU="${TZMODEM_APN2_MTU}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_ENABLE="${TZMODEM_APN2_ENABLE}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_NAT="${TZMODEM_APN2_NAT}" --section $UCI_SECTION
cfg -a TZ_MUTILAPN2_NAT_LOOKBACK="${TZMODEM_APN2_NATLOOKBACK}" --section $UCI_SECTION


if [ "${TZMODEM_ENABLE_ECGI_LOCK}" = "1" ]; then
	cfg -a TZ_ENABLE_ECGI_LOCK=1 --section $UCI_SECTION 
else
	cfg -a TZ_ENABLE_ECGI_LOCK=0 --section $UCI_SECTION
fi

cfg -d TZ_ECGI_ID_LIST --section $UCI_SECTION
for temp in ${TZMODEM_ECGI_ID_LIST}
do
	cfg -p TZ_ECGI_ID_LIST="${temp}" --section $UCI_SECTION
done

cfg -c

